home *** CD-ROM | disk | FTP | other *** search
- #include <Types.h>
- #include <Resources.h>
- #include <Memory.h>
- #include "FastStrings.h"
-
- pascal void GetIndStr2(Str255 theString, short str2ID, short index)
- {
- Handle hStr2;
- register char *strPtr;
- register int i;
- register short indexMOD16;
- short *indexList;
- short numStrings;
-
- *theString = 0; // Initialize to the empty string.
-
- if ((hStr2 = GetResource('STR2', str2ID)) == nil)
- return;
-
- numStrings = *(short *)*hStr2;
- if (index < 1 || index > numStrings)
- return;
-
- indexList = ((short *)(*hStr2)) + 1;
- --index; // Make index zero base, to simplify calculations
-
- strPtr = ((char *)(*hStr2)) + indexList[index>>4]; // index >>4 == index /16
- // strPtr now points to first string in the block of 16
-
- indexMOD16 = index & 0x0F;
- for (i=0; i < indexMOD16; ++i) // (index & 0x0F) == index % 16
- strPtr += (char *)*(unsigned char *)strPtr + 1;
-
- // Now copy the string into the caller's buffer
- BlockMove((Ptr)strPtr, (Ptr)theString, (Size)*(unsigned char *)strPtr+1);
- }
-
-
- pascal void GetIndStr3(Str255 theString, short strIID, short index)
- {
- Handle hStr2;
- register char *strPtr;
- register int i;
- short numStrings;
- short effectiveID;
- short effectiveIndex;
-
- *theString = 0; // Initialize to the empty string.
-
- --index; // Make index zero base, to simplify calculations
- effectiveIndex = index & 0x0f;
- effectiveID = ((strIID - 128) << 12) + (index>>4) + 1;
-
-
- if ((hStr2 = GetResource('STR3', effectiveID)) == nil)
- return;
-
- numStrings = *(short *)*hStr2;
- if (effectiveIndex >= numStrings)
- return;
-
- strPtr = ((char *)(*hStr2)) + 2; // Skip past the Number of strings entry
-
- for (i=0; i < effectiveIndex; ++i)
- strPtr += (char *)*(unsigned char *)strPtr + 1;
-
- // Now copy the string into the caller's buffer
- BlockMove((Ptr)strPtr, (Ptr)theString, (Size)*(unsigned char *)strPtr+1);
-
- }
-